package org.aplombh.java.interview.newcoder;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;

public class HJ41_称砝码 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            HashSet<Integer> res = new HashSet<>();
            res.add(0);

            int n = in.nextInt();
            int[] w = new int[n];
            ArrayList<Integer> all = new ArrayList<>();

            for (int i = 0; i < n; i++) {
                w[i] = in.nextInt();
            }
            for (int i = 0; i < n; i++) {
                int k = in.nextInt();
                for (int j = 1; j <= k; j++) {
                    all.add(w[i]);
                }
            }
            for (Integer value : all) {
                ArrayList<Integer> tmp = new ArrayList<>(res);
                for (Integer integer : tmp) {
                    res.add(value + integer);
                }
            }
            System.out.println(res.size());
        }
    }
}